package com.learn.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
//@Aspect
@Slf4j
public class MyAspect1 {
    @Pointcut("execution(* com.learn.service.impl.*.*(..))")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
        log.info("Around Before...");
        Object result = joinPoint.proceed();
        log.info("Around After...");
        return result;
    }

    @Before("pt()")
    public void before(){
        log.info("Before...");
    }

    @After("pt()")
    public void after(){
        log.info("After...");
    }

    @AfterReturning("pt()")
    public void afterReturning(){
        log.info("AfterReturning...");
    }


    @AfterThrowing("pt()")
    public void afterThrowing(){
        log.info("AfterThrowing...");
    }
}
